import Http from '@/utils/http';
import { getConfig } from '@/utils/config';
import { IUser } from '@/interfaces/entity';
import { getToken } from '@/utils/helper';
import { IResponse } from '@/interfaces/service';

const http = Http.create({
  baseURL: getConfig('apiUrl'),
});

/**
 * 获取用户信息
 * @returns {Promise<void>}
 */
export function getUserInfo() {
  return http.get<IUser>({
    path: '/api/passport/getUserInfo',
    headers: {
      Authorization: getToken()!,
    },
  });
}

/**
 * 登出
 */
export function logout() {
  return http.get<IResponse<null>>('/api/passport/logout');
}
